package com.zerdoor.service.impl;

import com.zerdoor.dao.IChatManageDao;
import com.zerdoor.model.ChatingRecord;
import com.zerdoor.service.IChatManageService;
import com.zerdoor.util.chatRecord.ChatingRecordOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 聊天管理业务层接口实现类
 * Created by zhongjieyu on 2014/12/8.
 */
@Service
public class ChatManageServiceImpl implements IChatManageService {

    @Autowired
    private IChatManageDao chatManageDao;

    @Override
    public List<ChatingRecord> findChatingRecordList(String channel, String path) throws Exception {


        //序列化方式实现聊天记录查询
        return  ChatingRecordOperation.getChatingRecordList(path, channel);
    }


    @Override
    public List<Map<String, String>> findInItemNameByUserId(String userType, int userId) throws Exception {

        Map<String,Integer> param = new HashMap<String, Integer>();

        //0为艺术家，否则为发包方
        if("0".equals(userType)){
            param.put("artist_id",userId);
        }else{
            param.put("baile_id",userId);

        }

        return chatManageDao.findInItemNameByUserId(param);
    }

    @Override
    public List<Map<String, String>> findContractByItemId(Map param) throws Exception {


        return chatManageDao.findContractByItemId(param);
    }



}
